<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的订单-青鸟优品</title>
    <link rel="stylesheet" href="./assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="./assets/css/common.css">
    <script src="./assets/js/jquery.js"></script>
    <script src="./assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="./assets/layer/layer.js"></script>
    <script src="./assets/js/common.js"></script>
    <script src="./assets/js/ucenter.js"></script>
</head>

<body>

    <nav class="navbar navbar-fixed-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="./index.html">青鸟商城</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-left">
                    <li class="active"><a href="#">热门推荐 <span class="sr-only">(current)</span></a></li>
                    <li><a href="#">国际品牌</a></li>
                    <li><a href="#">数码电器</a></li>
                    <li><a href="#">智能手机</a></li>
                    <li><a href="#">每日特价</a></li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="./ucenter.html">
                            <i class="glyphicon glyphicon-user"></i>
                            个人中心
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <i class="glyphicon glyphicon-off"></i>
                            安全退出</a>
                    </li>
                </ul>

            </div>
        </div>
    </nav>

    <div class="container user-info">
        <div class="row">
            <div class="col-xs-2">
                <ul class="nav nav-pills nav-stacked ">
                    <div class="avatar">
                        <img src="./uploads/avatar/01.jpg" class="img-circle user-avatar">
                    </div>
                    <hr>
                    <li role="presentation"><a href="./ucenter.html">会员中心</a></li>
                    <li role="presentation"  class="active"><a href="./order-list.html">我的订单</a></li>
                    <li role="presentation"><a href="./update-info.html">信息设置</a></li>
                    <li role="presentation"><a href="./reset-pwd.html">重置密码</a></li>
                    <li role="presentation"><a href="./address.html">收货地址</a></li>

                </ul>
            </div>
            <div class="col-xs-10 order-list">

                <!-- <table class="table table-bordered">
                    <tr class="active">
                        <td style="width: 400px;">
                            <span class="text-muted">订单号： 99316768860</span> 
                            <span class="text-muted">2019-07-10 22:31:47</span>
                        </td>
                        <td>支付方式</td>
                        <td>支付状态</td>
                        <td>订单状态</td>
                        <td>订单金额</td>
                        <td>操作</td>
                    </tr>
                    <tbody>

                        <tr class="cart-item">
                        <td>

                            <div class="media">
                                <div class="media-left">
                                    <a href="#">
                                        <img src="./uploads/10.png" alt="" style="width: 100px;">
                                    </a>
                                </div>
                                <div class="media-body"  style="width: 100px;">
                                    珀莱雅活能密集补水保湿套装化妆品套装女士护肤品洁面水乳正品 洁水乳保湿
                                </div>
                            </div>

                        </td>
                        <td>
                            <span>在线支付</span>
                        </td>
                        <td>
                            未支付
                        </td>
                        <td>
                            未发货
                        </td>
                        <td>
                            <span class="price">&yen;3999</span>
                        </td>
                        <td>
                            <a class="text-danger">删除</a>
                        </td>
                    </tr>
                    </tbody>
                </table> -->

                
            </div>
        </div>
    </div>


    <div class="container-fluid footer">
        <div class="row">
            <div class="col-lg-12">
                Copyright 2019 by www.braccp.com 北京畅想唯优信息技术有限公司 All rights reserved.
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                联系电话：029-88212666 地址：西安市雁塔区电子一路 石油大学北门工会楼二层
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                备案号：陕ICP备19013769号-1
            </div>
        </div>
    </div>
</body>
<script>
    // 校验登录凭证
    auth();
    // 获取订单列表
    $.ajax({
        url:'/apis/index.php?c=order&a=list',
        dataType:'json',
        headers:{
            Token:localStorage.getItem('token')
        }
    }).then(res=>{
        // console.log(res);
        if(res.errcode===0){
            // 渲染订单列表
            var html='';
            res.data.forEach(order=>{
                html+=`
                <table class="table table-bordered">
                    <tr class="active">
                        <td style="width: 400px;">
                            <span class="text-muted">订单号： ${order.order_no}</span><br/>
                            <span class="text-muted">${order.createtime}</span>
                        </td>
                        <td>支付方式</td>
                        <td>支付状态</td>
                        <td>订单状态</td>
                        <td>订单金额</td>
                        <td>操作</td>
                    </tr>
                    <tr class="cart-item">
                        <td>

                            <div class="media">
                                <div class="media-left">
                                    <a href="#">
                                        <img src="${order.items[0].product_cover}" alt="" style="width: 100px;">
                                    </a>
                                </div>
                                <div class="media-body"  style="width: 100px;">
                                    ${order.items[0].product_name}
                                </div>
                            </div>

                        </td>
                        <td>
                            <span>${order.pay_way==1?'在线支付':'货到付款'}</span>
                        </td>
                        <td>
                            ${order.pay_status==1?'未支付':'已支付'}
                        </td>
                        <td>
                            ${order.status==1?'未发货':'已发货'}
                        </td>
                        <td>
                            <span class="price">&yen;${order.amount}</span>
                        </td>
                        <td>
                            <a href="#" class="btn btn-xs btn-danger btn-del" order-id="${order.id}">删除</a>
                            <br/>
                            <a href="/order-detail.html?id=${order.id}" class="btn btn-xs btn-info">详情</a>
                        </td>
                    </tr>
                    </table>
                `;
                // 渲染页面
                $(".order-list").html(html);
            });
        }
    });
    // 删除订单
    $(".order-list").on('click','.btn-del',function(){
        // console.log('删除订单');
        if(!confirm('确认删除?')){
            return false;
        }
        var id=$(this).attr('order-id');
        // console.log(orderId);
        // 发送请求
        $.ajax({
            url:'/apis/index.php?c=order&a=del',
            data:{id},
            dataType:'json',
            headers:{
                Token:localStorage.getItem('token')
            }
        }).then(res=>{
            if(res.errcode===0){
                // 移除页面中被删除的订单
                $(this).parents('table').remove();
            }else{
                layer.msg('删除失败, 请稍后重试');
            }
        })
    });
</script>
</html>